<template>
  <div class="nav-head top">
    <div class="content">
      <div class="box-1">
        <el-row :gutter="40">
          <el-col :span="4">
            <img
              src="https://res.songzhaopian.cn/rouzao-custom-platform/icon-v2.png"
              alt=""
            />
          </el-col>
          <el-col :span="16">
            <div class="nav-tab">
              <el-row :gutter="40">
                <el-col :span="colSpanTab">
                  <el-button @click="toPath('/home')" text>首页</el-button>
                </el-col>
                <el-col :span="colSpanTab">
                  <el-button @click="toPath('/studyCenter')" text
                    >学习中心</el-button
                  >
                </el-col>
                <el-col :span="colSpanTab">
                  <el-button @click="toPath('/products')" text
                    >全部商品</el-button
                  >
                </el-col>
                <el-col :span="colSpanTab">
                  <el-button @click="toPath('/myProduct/list')" text
                    >我的商品</el-button
                  >
                </el-col>
                <el-col :span="colSpanTab">
                  <el-button text>订单管理</el-button>
                </el-col>
              </el-row>
            </div>
            <el-input
              v-model="value"
              style="width: 200px"
              placeholder="搜索你想要的商品"
            >
              <template #append>搜索</template>
            </el-input>
          </el-col>
          <el-col :span="4">
            <el-divider direction="vertical" />
            <div class="icon-wrap">
              <i class="iconfont icon-remind"></i>
            </div>
            <el-divider direction="vertical" />
            <div class="flex items-center user-wrap">
              <el-avatar :size="35"> user </el-avatar>
              <span class="pl-10">Nick</span>
              <i class="iconfont icon-sort-down"></i>
              <div class="user-list">
                <div class="content">
                  <div class="user-item" @click="toPath('/user/my')">
                    个人中心
                  </div>
                  <div class="mt-20 user-item">退出登录</div>
                </div>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const value = ref('')
const colSpanTab = ref(4)
const router = useRouter()
const route = useRoute()

function toPath(path) {
  router.push({
    path,
  })
}
</script>

<style lang="scss" scoped>
.nav-head {
  height: 60px;
  box-shadow: rgba(0, 0, 0, 0.12) 0px 0px 10px;
  position: relative;
  z-index: 1;
  background-image: url('http://res.songzhaopian.cn/rouzao-custom-platform/assets/bg-2b457fc3.jpg');
  background-position: center center;
  .content {
    width: 1180px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    .icon-wrap {
      i {
        cursor: pointer;
      }
    }
    .user-wrap {
      position: relative;
      .user-list {
        display: none;
        .user-item {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 240px;
          height: 40px;
          box-sizing: border-box;
          border: 1px solid #e6e8ec;
          border-radius: 90px;
          font-size: 14px;
          cursor: pointer;
          color: #23262f;
        }
      }
      &:hover {
        .user-list {
          z-index: 9999;
          display: block;
          position: absolute;
          top: 10px;
          right: 0;
          .content {
            display: flex;
            flex-direction: column;
            margin-top: 40px;
            width: 292px;
            padding: 30px 26px;
            box-sizing: border-box;
            background: #fcfcfd;
            border-radius: 5px;
            z-index: 10;
            box-shadow: 0 40px 32px -24px rgba(15, 15, 15, 0.12);
          }
        }
      }
    }
  }
  .iconfont {
    padding: 0 10px;
    font-size: 20px;
  }
  .el-row {
    .el-col {
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .slogan {
      background-image: url('//res.songzhaopian.cn/rouzao-custom-platform/solgen.png');
      margin-left: 16px;
      height: 18px;
      width: 228px;
      background-size: contain;
      font-size: 0px;
      background-repeat: no-repeat;
    }
    img {
      height: 30px;
    }
  }
  .nav-tab {
    .el-button {
      font-size: 16px;
    }
  }
}
</style>
